/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.pay.alipay;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import com.alipay.android.app.IAlixPay;
import com.alipay.android.app.IAlixPay.a;
import com.alipay.android.app.IRemoteServiceCallback;
import com.alipay.android.app.IRemoteServiceCallback.a;
import com.qihoo.gamecenter.sdk.pay.k.c;

public class QiHooPayMobileSecurePayer implements ServiceConnection {
    static String a = "MobileSecurePayer";
    Integer b = Integer.valueOf(0);
    IAlixPay c = null;
    boolean d = false;
    Activity e = null;
    public IRemoteServiceCallback f = new IRemoteServiceCallback.a() {
        public void a(String paramString1, String paramString2, int paramInt, Bundle paramBundle) {
            Intent localIntent = new Intent("android.intent.action.MAIN", null);
            if (paramBundle == null)
                paramBundle = new Bundle();
            try {
                paramBundle.putInt("CallingPid", paramInt);
                localIntent.putExtras(paramBundle);
            } catch (Exception localException) {
                c.c(QiHooPayMobileSecurePayer.a, new Object[] { localException.toString() });
            }
            localIntent.setClassName(paramString1, paramString2);
            QiHooPayMobileSecurePayer.this.e.startActivity(localIntent);
            c.a(QiHooPayMobileSecurePayer.a, new Object[] { "startActivity, packageName=", paramString1,
                    ", className=", paramString2 });
        }
    };

    public void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder) {
        synchronized (this.b) {
            this.c = IAlixPay.a.a(paramIBinder);
            this.b.notify();
        }
    }

    public void onServiceDisconnected(ComponentName paramComponentName) {
        this.c = null;
    }

    public boolean a(String paramString, Handler paramHandler, int paramInt, Activity paramActivity)
  {
    if (this.d)
      return false;
    this.d = true;
    this.e = paramActivity;
    if (this.c == null)
      this.e.getApplicationContext().bindService(new Intent(IAlixPay.class.getName()), this, 1);
    new Thread(new Runnable(paramString, paramInt, paramHandler)
    {
      public void run()
      {
        Message localMessage;
        try
        {
          synchronized (QiHooPayMobileSecurePayer.this.b)
          {
            if (QiHooPayMobileSecurePayer.this.c == null)
              QiHooPayMobileSecurePayer.this.b.wait();
          }
          QiHooPayMobileSecurePayer.this.c.a(QiHooPayMobileSecurePayer.this.f);
          ??? = QiHooPayMobileSecurePayer.this.c.a(this.a);
          QiHooPayMobileSecurePayer.this.d = false;
          QiHooPayMobileSecurePayer.this.c.b(QiHooPayMobileSecurePayer.this.f);
          QiHooPayMobileSecurePayer.this.e.getApplicationContext().unbindService(QiHooPayMobileSecurePayer.this);
          localMessage = new Message();
          localMessage.what = this.b;
          localMessage.obj = ???;
          this.c.sendMessage(localMessage);
        }
        catch (Exception localException)
        {
          c.c(QiHooPayMobileSecurePayer.a, new Object[] { localException.toString() });
          localMessage = new Message();
          localMessage.what = this.b;
          localMessage.obj = localException.toString();
          this.c.sendMessage(localMessage);
        }
      }
    }).start();
    return true;
  }
}